#ifndef STATESFACTORY
#define STATESFACTORY

#include <app\session.h>

#include <map>

using namespace std;

class sessionState;

class statesFactory {

  static statesFactory *_instance;

  statesFactory();
  statesFactory(statesFactory &);
  statesFactory * operator=(statesFactory &);
  ~statesFactory();

public:

   typedef sessionState* (*createStateCallback)();

private:

   typedef std::map<unsigned int, createStateCallback> statesMap;

public:

  static statesFactory &instance();

  bool registerState(unsigned int stateId, createStateCallback createFn);
  bool unregisterState(unsigned int stateId);
  sessionState* createState(unsigned int stateId);

private:

  statesMap states;
  statesMap::iterator istates;
};

#endif